<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>expanding-cards</title>
    <style>
        * {
            box-sizing: border-box;
        }

        body {
            font-family: 'Muli', sans-serif;
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100vh;
            overflow: hidden;
            margin: 0;
            
        }
       
        .container {
            display: flex;
            width: 90vw;
        }

        .picture{
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            height: 80vh;
            border-radius: 50px;
            cursor: pointer;
            color: #fff;
            flex: 0.5;
            margin: 12px;
            position: relative;
            transition: all 0.7s ease-in;
        }

        .picture h3 {
            font-size: 24px;
            position: absolute;
            bottom: 20px;
            left: 30px;
            margin: 0;
            opacity: 0;
            color: #fff;
        }

        .picture.active {
            flex: 5;
        }

        .picture.active h3 {
            opacity: 1;
            transition: opcity 0.3s ease-in 0.4s;
        }

        @media (max-width: 480px) {
            .container {
                width: 100vw;
            }

            .panel:nth-of-type(4),
            .panel:nth-of-type(5) {
                display: none;
            }
        }
    </style>
</head>

<body>

    <div class="container">   
    <div class="picture active"
        style="background-image: url('https://images.unsplash.com/photo-1558979158-65a1eaa08691?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80')">
        <h3>Explore The World</h3>
    </div>
    <div class="picture"
        style="background-image: url('https://images.unsplash.com/photo-1572276596237-5db2c3e16c5d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80')">
        <h3>Wild Forest</h3>
    </div>
    <div class="picture"
        style="background-image: url('https://images.unsplash.com/photo-1507525428034-b723cf961d3e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1353&q=80')">
        <h3>Sunny Beach</h3>
    </div>
    <div class="picture"
        style="background-image: url('https://images.unsplash.com/photo-1551009175-8a68da93d5f9?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1351&q=80')">
        <h3>City on Winter</h3>
    </div>
    <div class="picture"
        style="background-image: url('https://images.unsplash.com/photo-1549880338-65ddcdfd017b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80')">
        <h3>Mountains - Clouds</h3>
    </div>
    </div>

    <script>
        let pictures = document.querySelectorAll('.picture')

        for(let i=0;i < pictures.length;i++){
            pictures[i].addEventListener('click',function(){
                // 选出唯一的那个active ，删除类
                document.querySelector('.picture.active').classList.remove('active')
                // 鼠标点击 加上active 这个类
                this.classList.add('active')
            }) 
        }
    </script>
</body>

</html>